package com.whitedust.top100;

import com.whitedust.structure.TreeNode;

/**
 *
 * @author A
 * @since 2025/11/17 19:12
 */

public class Top92 {
    public TreeNode invertTree(TreeNode root) {
        rotate(root);
        return root;
    }

    private void rotate(TreeNode node) {
        if (node == null) return;
        TreeNode tmp = node.left;
        node.left = node.right;
        node.right = tmp;
        rotate(node.left);
        rotate(node.right);
    }
}
